<?php
class Auth{
	const SESSION_NAME = "Auth_Entity";
	/**
	 * Check Authentication
	 * @param array $route
	 */
	public static function Authentication($route){
		if(!Auth::hasSession()){
			$route[Configuration::CONTROLLER] = "UserSystem";
			$route[Configuration::ACTION] = "login";
			$route[Configuration::VIEW] = "default";
			$route[Configuration::VIEW_TYPE] = "html";
		}		
		return $route;
	}
	
	/**
	 * Start Auth session.
	 * @param Object $entity
	 */
	public static function startSession($entity){
		$_SESSION[Auth::SESSION_NAME] = $entity;
	}
	/**
	 * End Auth session.
	 */
	public static function endSession(){
		unset($_SESSION[Auth::SESSION_NAME]);
	}
	/**
	 * Check Auth session
	 * @return true or false.
	 */
	public static function hasSession(){
		return isset($_SESSION[Auth::SESSION_NAME]) ? true : false;
	} 
	public static function getSession(){
		return isset($_SESSION[Auth::SESSION_NAME]) ? $_SESSION[Auth::SESSION_NAME] : null;
	}
}